<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var camelMatch = function (queries, pattern) {
      return queries.map((query) => {
        // i 指针对应 query，j 指针对应 pattern
        let i = 0, j = 0;
        while (i < query.length) {
          // 如果对比的两个字符相等就让指针前进一步
          if (query[i] === pattern[j]) {
            i++;
            // 这里判断的原因是防止 j 超过 pattern 的长度
            if (j < pattern.length) {
              j++;
            }
          } else {
            // 如果对比的两个字符不相等，当 query 的当前字符是大写则直接返回 false
            if (isUpper(query[i])) {
              return false;
            } else {
              // 其他情况直接让 i 指针前进即可
              i++;
            }
          }
        }
        // 如果成功匹配，则最后两个指针都会达到对应字符串的最后
        return i === query.length && j === pattern.length;
      });
    };
    function isUpper(c) {
      const code = c.codePointAt();
      return code >= 65 && code <= 90;
    }
    console.log(camelMatch(queries = ["FooBar", "FooBarTest", "FootBall", "FrameBuffer", "ForceFeedBack"], pattern = "FB"))
  </script>
</body>

</html>